const { defineConfig } = require('@vue/cli-service')
const path = require("path");
function resolve(dir) {
  return path.join(__dirname, dir);
}
module.exports = defineConfig({
  transpileDependencies: true,
  chainWebpack (config) {
    // set svg-sprite-loader
    config.module
      .rule('svg')
      .exclude.add(resolve('src/icons'))
      .end()
    config.module
      .rule('icons')
      .test(/\.svg$/)
      .include.add(resolve('src/icons'))
      .end()
      .use('svg-sprite-loader')
      .loader('svg-sprite-loader')
      .options({
        symbolId: 'icon-[name]'
      })
      .end()
  }
})

module.exports = {
  lintOnSave: false, // 禁用保存时的 ESLint 检查
  devServer: {
    port: 1600 // 你想要设置的端口号
  },
  chainWebpack: config => {
    const svgRule = config.module.rule('svg');
    svgRule.uses.clear();
    svgRule.use('svg-sprite-loader')
      .loader('svg-sprite-loader')
      .options({ symbolId: 'icon-[name]' });
    svgRule.use('svgo-loader')
      .loader('svgo-loader')
      .options({
        plugins: [
          /*{
            removeTitle: true
          },*/
          /*{
            convertColors: { shorthex: false }
          },*/
          /*{
            convertPathData: false
          }*/
          {
            name: 'removeAttrs',
            params: {
              attrs: 'fill'
            }
          }
        ]
      });
  }
};
